package com.rencheqi.web.driver.controller;

import com.rencheqi.common.core.controller.BaseController;
import com.rencheqi.common.core.domain.AjaxResult;
import com.rencheqi.common.core.page.TableDataInfo;
import com.rencheqi.web.driver.domain.DriverInfo;
import com.rencheqi.web.driver.service.DriverInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 驾驶人员信息管理 控制层实现类驾驶人员基本信息
 *
 * @author xiexin
 * @version DriverInfoController.java, v0.1 2025年 05月 19日 10:52 xiexin Exp $
 */
@RestController
@RequestMapping("/driver")
@Api(tags = "驾驶人员信息管理")
public class DriverInfoController extends BaseController {

    @Resource
    private DriverInfoService driverInfoService;

    /**
     * 获取驾驶人员信息列表
     */
    //@PreAuthorize("@ss.hasPermi('driver:info:query')")
    @GetMapping("/list")
    @ApiOperation(value = "获取驾驶人员信息列表")
    public TableDataInfo list(DriverInfo driverInfo) {
        startPage();
        List<DriverInfo> list = driverInfoService.selectDriverInfoList(driverInfo);
        return getDataTable(list);
    }

    /**
     * 根据id详细信息
     */
    //@PreAuthorize("@ss.hasPermi('driver:info:query')")
    @ApiOperation(value = "根据id获取驾驶人员详细信息")
    @GetMapping(value = "/getInfo")
    public AjaxResult getInfo(@RequestParam("id") String id) {
        return success(driverInfoService.selectDriverInfoById(id));
    }

    /**
     * 新增驾驶人员基础信息
     */
    //@PreAuthorize("@ss.hasPermi('driver:info:add')")
    //@Log(title = "驾驶人员-基本信息", businessType = BusinessType.INSERT)
    @ApiOperation(value = "新增驾驶人员基础信息")
    @PostMapping("add")
    public AjaxResult add(@Validated @RequestBody DriverInfo driverInfo) {
        return toAjax(driverInfoService.insertDriverInfo(driverInfo));
    }

    /**
     * 修改驾驶人员基础信息
     */
    //@PreAuthorize("@ss.hasPermi('driver:info:edit')")
    //@Log(title = "参数管理", businessType = BusinessType.UPDATE)
    @ApiOperation(value = "修改驾驶人员基础信息")
    @PostMapping("/edit")
    public AjaxResult edit(@Validated @RequestBody DriverInfo driverInfo) {
        return toAjax(driverInfoService.updateDriverInfo(driverInfo));
    }

    /**
     * 删除驾驶人员基础信息
     */
    //@PreAuthorize("@ss.hasPermi('driver:info:delete')")
    //@Log(title = "参数管理", businessType = BusinessType.DELETE)
    @ApiOperation(value = "删除驾驶人员基础信息")
    @GetMapping("/delete")
    public AjaxResult delete(@RequestParam("id") String id) {
        return success(driverInfoService.deleteDriverInfoById(id));
    }
}
